package cn.z2huo.demo.spring.cloud.alibaba.provider.controller;

import cn.hutool.core.util.RuntimeUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>服务提供者接口
 *
 * @author z2huo
 */
@RestController
@RequestMapping("/provider")
@Slf4j
public class ProviderController {

    @GetMapping("/hello")
    public String hello() {
        return "welcome from provider. provider app PID is " + RuntimeUtil.getPid()
                + ", random string " + RandomStringUtils.randomAlphabetic(8);
    }

    @GetMapping(value = "/echo/{string}")
    public String echo(@PathVariable String string) {
        log.info("API /provider/echo/{}", string);
        return "Hello Nacos Discovery " + string;
    }
}
